/********************************************************************************
* @File name: joystick.h
* @Author: Loganx
* @Gitee: https://gitee.com/loganxiang/lgxsmartcar
* @Version: 1.0(2025-10-09)
* @Description: STC32H单片机遥杆
********************************************************************************
* 本软件使用了STC的STC32G官方库
********************************************************************************/
#ifndef _LGX_JOYSTICK
#define _LGX_JOYSTICK

#include "Config.h"
#include "STC32G_GPIO.h"
#include "STC32G_ADC.h"
#include "STC32G_NVIC.h"

//joystick signal threshold
#define JOYSTICK_LEFT		12
#define JOYSTICK_RIGHT      4
#define JOYSTICK_UP			12
#define JOYSTICK_DOWN		4

#define JOYS_CALI_MIN	    0
#define JOYS_CALI_MID	    2047
#define JOYS_CALI_MAX	    4095

//joystick signal timeout(100ms)
#define JOYSIG_TIMEOUT	10

extern uint8 JoysX,JoysY;
extern uint8 JoySigUp,JoySigDown,JoySigLeft,JoySigRight;

void JoystickInit(void);
void SystickCallbackJoys(void);

#endif